/**
 * Copyright(c) 2014 Xunton Solutions
 *
 * History:
 *   15-8-31 下午6:39 Created by dwzhang
 */
package com.jade.bss.service.push.impl;

import com.jade.bss.service.push.*;
import com.jade.framework.base.util.Parameters;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * 抽象的Push服务。
 *
 * @author <a href="mailto:dwzhang@xunton.com">dwzhang</a> 
 * @version 1.0 15-8-31 下午6:39
 */
public abstract class AbstractPushService
        implements PushService
{
    protected Log log = LogFactory.getLog(this.getClass());
    protected AppConfig appConfig;

    public void setAppConfig(AppConfig appConfig)
    {
        this.appConfig = appConfig;
    }

    public PushResult sendPush(String appCode, String audienceType, String[] audiences, boolean isAnd,
                               String title, String notification, Parameters serviceParams, Parameters pushParams)
            throws PushException
    {
        return sendPush(appCode, null, audienceType, audiences, isAnd, title, notification, serviceParams, pushParams);
    }

    public PushResult sendPush(String appCode, String platform, String audienceType, String[] audiences, boolean isAnd,
                               String title, String notification, Parameters serviceParams, Parameters pushParams)
            throws PushException
    {
        return pushNotification(appCode, platform, audienceType, audiences, isAnd, title, notification, serviceParams,
                pushParams);
    }

    public PushResult pushNotification(String appCode, String audienceType, String[] audiences, boolean isAnd,
                                       String title, String notification, Parameters serviceParams,
                                       Parameters pushParams)
            throws PushException
    {
        return pushNotification(appCode, null, audienceType, audiences, isAnd, title, notification, serviceParams,
                pushParams);
    }

    public PushResult pushMessage(String appCode, String audienceType, String[] audiences, boolean isAnd, String title,
                                  String notification, Parameters serviceParams, Parameters pushParams)
            throws PushException
    {
        return pushMessage(appCode, null, audienceType, audiences, isAnd, title, notification, serviceParams,
                pushParams);
    }
}
